package com.roundarchisobar.njariwala.netflix.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.roundarchisobar.njariwala.netflix.dto.NetflixCatalogTitle;
import com.roundarchisobar.njariwala.netflix.request.VideoDetailRequest;
import com.roundarchisobar.njariwala.netflix.service.NetflixSearchService;

@Controller
public class VideoController {

	@Autowired
	private NetflixSearchService netflixSearchService;

	@RequestMapping(value = "/videodetails", method = RequestMethod.GET)
	public String videoDetailHandler(VideoDetailRequest videoDetailRequest, HttpServletRequest request, Model model){
		NetflixCatalogTitle netflixCatalogTitle = netflixSearchService.getVideoDetails(videoDetailRequest.getMovieSeriesId(), videoDetailRequest.getMovieSeriesType());
		model.addAttribute("netflixCatalogTitle", netflixCatalogTitle);
		return "video";
	}
}
